package com.teen9g.infoplatformserver.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teen9g.entity.SingleRecentEdit;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface RecentEditMapper extends BaseMapper<SingleRecentEdit> {
    /**
     * 获取最近15条编辑记录
     *
     * @return
     */
    @Select("select * from single_updates" +
            " order by update_time desc limit 15")
    List<SingleRecentEdit> getRecentEdit();

    /**
     * 从数据库中获取食堂店铺相关且id为{id}的所有编辑记录
     *
     * @return
     */
    @Select("select * from single_updates" +
            " where content_category='食堂店铺' and content_id=#{id} " +
            "order by update_time desc ")
    List<SingleRecentEdit> CS_getRecentEditById(Integer id);

    /**
     * 获取最近15条被编辑的食堂店铺相关的文章
     *
     * @return
     */
    @Select("select * from single_updates" +
            " where content_category='食堂店铺' order by update_time desc limit 15")
    List<SingleRecentEdit> CS_getRecentEdit();

    @Select("select * from single_updates" +
            " where content_category='教学楼和学院楼' order by update_time desc limit 15")
    List<SingleRecentEdit> TB_getRecentEdit();

    @Select("select * from single_updates" +
            " where content_category='教学楼和学院楼' and content_id=#{id} " +
            "order by update_time desc ")
    List<SingleRecentEdit> TB_getRecentEditById(Integer id);

    @Select("select * from single_updates" +
            " where content_category='舞萌中二' and content_id=#{id} " +
            "order by update_time desc ")
    List<SingleRecentEdit> MC_getRecentEditById(Integer id);

    @Select("select * from single_updates" +
            " where content_category='运动场' and content_id=#{id} " +
            "order by update_time desc ")
    List<SingleRecentEdit> PG_getRecentEditById(Integer id);
}
